﻿// ConsoleApplication1.cpp : 此文件包含 "main" 函数。程序执行将在此处开始并结束。
//
#include <functional>
#include <stack>
#include <list>
#include <iostream>
#include <string>
#include <vector>
#include <fstream>
#include <sstream>
#include <forward_list>
#include <algorithm>
#include <numeric> 
#include <map>
#include<cstdio>

#include "Query.h"
ostream& print(ostream& os, const QueryResult& qr)
{
	os << qr.sought << " occors " << qr.lines->size() << " " << " times " << endl;//输出关键词和出现次数
	for (auto num : *qr.lines)  
	{
		os << " \t(line " << num + 1 << ")" << *(qr.file->begin() + num) << endl;//输出关键词所在行
	}
	return os;
}
/*15文本查询改进*/
int main()
{
	ifstream use("data");
	TextQuery file = use;
	Query q = Query("fiery") & Query("bird") | Query("wind");
	const auto results = q.eval(file);
	cout << "Executing Query for: " << q << endl;
	print(cout, results) << endl;
	   
	
	return 0;
}

//int main()
//{
//	string A1 = "nansh";
//	bulk_quote bq(A1, 80, 5, 0.2);
//	//print_total(std::cout, bq, 10);
//
//	std::vector<std::shared_ptr<Quote>> basket;
//	basket.push_back(std::make_shared<bulk_quote>(bq));
//
//	Basket basket_object;
//	for (int i = 0; i < 10; ++i)
//	{
//		basket_object.add_item(bq);
//	}
//	basket_object.total_receipt(std::cout);
//
//
//   
//	return 0;
//}





   
//int main()
//{
//	std::ifstream f("data.txt");
//	StrBlob b1;
//	for (std::string s; std::getline(f,s);)
//	{
//		b1.push_back(s);
//	}
//
//	for (StrBlobPtr beg(b1.begin()), ed(b1.end()); beg.big_small() != ed.big_small(); beg.incr())
//		std::cout << beg.deref() << std::endl;
//	return 0;
//}